package net.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.pojo.Product;
import net.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("/product")
public class ProductController {
    @Autowired
    ProductService productService;

    @RequestMapping("/findAllProduct")
    public String findAllProduct(Integer currentPage,Model model) {
        PageHelper.startPage(currentPage,6);
        List<Product> list = productService.findAllProduct();
        PageInfo info = new PageInfo(list);
        //根据点击数 降序排序
        List<Product> clickList = productService.findByClick();
        //根据评论数 ，降序排序
        List<Product> commentList = productService.findByComment();

        model.addAttribute("list",list);
        model.addAttribute("info",info);
        model.addAttribute("clickList",clickList);
        model.addAttribute("commentList",commentList);
        return "/client/foodie.jsp";
    }
}
